package pe.edu.pucp.notasmoviles.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LoggingAroundAspect {
	private Logger logger = Logger.getLogger(LoggingAroundAspect.class);

	@Around("pe.edu.pucp.notasmoviles.aop.SystemArchitecture.servicePointcut()")
	public Object around(ProceedingJoinPoint pjp) throws Throwable {
		Object ret= null;
		try {
			logger.debug("Interceptando around before");
			Object[] args = pjp.getArgs(); // Obtener los argumentos del metodo
			ret = pjp.proceed(args); // Obtener el valor de retorno del metodo
			logger.debug("Interceptando around after-returning");
		} catch (Exception e) {
			logger.debug("Interceptando around after-throwing");
			throw e;
		} finally {
			logger.debug("Interceptando around after");
		}
		return ret;
	}

}
